﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.RemoveDuplicates
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 0, 0, 1, 1, 1, 2, 2, 3, 3, 4 };
            Console.WriteLine(RemoveDuplicates(nums));
            Console.ReadKey();
        }

        public static int RemoveDuplicates(int[] nums)
        {
            if (nums.Length == 0)
            {
                return 0;
            }

            int recordValue = nums[0];
            int recordIndex = 0;
            for (int i = 0; i < nums.Length; i++)
            {
                if (nums[i] > recordValue)
                {
                    recordIndex++;
                    recordValue = nums[i];
                    nums[recordIndex] = nums[i];
                }
            }
            return recordIndex + 1;
        }
    }

}
